Subject: [PATCH] Add ability to disable controllers
---
Index: pkg/controller/broadcastjob/broadcastjob_controller.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/pkg/controller/broadcastjob/broadcastjob_controller.go b/pkg/controller/broadcastjob/broadcastjob_controller.go
--- a/pkg/controller/broadcastjob/broadcastjob_controller.go	(revision f41e27d4bfb63f0aa0addb35889bae3d43aede56)
+++ b/pkg/controller/broadcastjob/broadcastjob_controller.go	(date 1680208342919)
@@ -79,6 +79,9 @@
 // Add creates a new BroadcastJob Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller
 // and Start it when the Manager is Started.
 func Add(mgr manager.Manager) error {
+	if concurrentReconciles == 0 {
+		return nil
+	}
 	if !utildiscovery.DiscoverGVK(controllerKind) {
 		return nil
 	}
Index: pkg/controller/advancedcronjob/advancedcronjob_controller.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/pkg/controller/advancedcronjob/advancedcronjob_controller.go b/pkg/controller/advancedcronjob/advancedcronjob_controller.go
--- a/pkg/controller/advancedcronjob/advancedcronjob_controller.go	(revision f41e27d4bfb63f0aa0addb35889bae3d43aede56)
+++ b/pkg/controller/advancedcronjob/advancedcronjob_controller.go	(date 1680208342886)
@@ -55,6 +55,9 @@
 // Add creates a new AdvancedCronJob Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller
 // and Start it when the Manager is Started.
 func Add(mgr manager.Manager) error {
+	if concurrentReconciles == 0 {
+		return nil
+	}
 	if !utildiscovery.DiscoverGVK(controllerKind) {
 		return nil
 	}
Index: pkg/controller/workloadspread/workloadspread_controller.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/pkg/controller/workloadspread/workloadspread_controller.go b/pkg/controller/workloadspread/workloadspread_controller.go
--- a/pkg/controller/workloadspread/workloadspread_controller.go	(revision f41e27d4bfb63f0aa0addb35889bae3d43aede56)
+++ b/pkg/controller/workloadspread/workloadspread_controller.go	(date 1680208342850)
@@ -100,6 +100,9 @@
 // Add creates a new WorkloadSpread Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller
 // and Start it when the Manager is Started.
 func Add(mgr manager.Manager) error {
+	if concurrentReconciles == 0 {
+		return nil
+	}
 	if !utildiscovery.DiscoverGVK(controllerKruiseKindWS) {
 		return nil
 	}
Index: pkg/controller/statefulset/statefulset_controller.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/pkg/controller/statefulset/statefulset_controller.go b/pkg/controller/statefulset/statefulset_controller.go
--- a/pkg/controller/statefulset/statefulset_controller.go	(revision f41e27d4bfb63f0aa0addb35889bae3d43aede56)
+++ b/pkg/controller/statefulset/statefulset_controller.go	(date 1680208342991)
@@ -90,6 +90,9 @@
 // Add creates a new StatefulSet Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller
 // and Start it when the Manager is Started.
 func Add(mgr manager.Manager) error {
+	if concurrentReconciles == 0 {
+		return nil
+	}
 	if !utildiscovery.DiscoverGVK(controllerKind) {
 		return nil
 	}
Index: pkg/controller/podprobemarker/pod_probe_marker_controller.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/pkg/controller/podprobemarker/pod_probe_marker_controller.go b/pkg/controller/podprobemarker/pod_probe_marker_controller.go
--- a/pkg/controller/podprobemarker/pod_probe_marker_controller.go	(revision f41e27d4bfb63f0aa0addb35889bae3d43aede56)
+++ b/pkg/controller/podprobemarker/pod_probe_marker_controller.go	(date 1680208342968)
@@ -68,6 +68,9 @@
 // Add creates a new PodProbeMarker Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller
 // and Start it when the Manager is Started.
 func Add(mgr manager.Manager) error {
+	if concurrentReconciles == 0 {
+		return nil
+	}
 	if !utildiscovery.DiscoverGVK(controllerKind) || !utilfeature.DefaultFeatureGate.Enabled(features.PodProbeMarkerGate) {
 		return nil
 	}
Index: pkg/controller/containerrecreaterequest/crr_controller.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/pkg/controller/containerrecreaterequest/crr_controller.go b/pkg/controller/containerrecreaterequest/crr_controller.go
--- a/pkg/controller/containerrecreaterequest/crr_controller.go	(revision f41e27d4bfb63f0aa0addb35889bae3d43aede56)
+++ b/pkg/controller/containerrecreaterequest/crr_controller.go	(date 1680208342831)
@@ -64,6 +64,9 @@
 // Add creates a new ContainerRecreateRequest Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller
 // and Start it when the Manager is Started.
 func Add(mgr manager.Manager) error {
+	if concurrentReconciles == 0 {
+		return nil
+	}
 	if !utildiscovery.DiscoverGVK(controllerKind) || !utilfeature.DefaultFeatureGate.Enabled(features.KruiseDaemon) {
 		return nil
 	}
Index: pkg/controller/nodepodprobe/node_pod_probe_controller.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/pkg/controller/nodepodprobe/node_pod_probe_controller.go b/pkg/controller/nodepodprobe/node_pod_probe_controller.go
--- a/pkg/controller/nodepodprobe/node_pod_probe_controller.go	(revision f41e27d4bfb63f0aa0addb35889bae3d43aede56)
+++ b/pkg/controller/nodepodprobe/node_pod_probe_controller.go	(date 1680208342927)
@@ -63,6 +63,9 @@
 // Add creates a new NodePodProbe Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller
 // and Start it when the Manager is Started.
 func Add(mgr manager.Manager) error {
+	if concurrentReconciles == 0 {
+		return nil
+	}
 	if !utildiscovery.DiscoverGVK(controllerKind) || !utilfeature.DefaultFeatureGate.Enabled(features.PodProbeMarkerGate) {
 		return nil
 	}
Index: pkg/controller/uniteddeployment/uniteddeployment_controller.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/pkg/controller/uniteddeployment/uniteddeployment_controller.go b/pkg/controller/uniteddeployment/uniteddeployment_controller.go
--- a/pkg/controller/uniteddeployment/uniteddeployment_controller.go	(revision f41e27d4bfb63f0aa0addb35889bae3d43aede56)
+++ b/pkg/controller/uniteddeployment/uniteddeployment_controller.go	(date 1680208342934)
@@ -75,6 +75,9 @@
 // Add creates a new UnitedDeployment Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller
 // and Start it when the Manager is Started.
 func Add(mgr manager.Manager) error {
+	if concurrentReconciles == 0 {
+		return nil
+	}
 	if !utildiscovery.DiscoverGVK(controllerKind) {
 		return nil
 	}
Index: pkg/controller/resourcedistribution/resourcedistribution_controller.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/pkg/controller/resourcedistribution/resourcedistribution_controller.go b/pkg/controller/resourcedistribution/resourcedistribution_controller.go
--- a/pkg/controller/resourcedistribution/resourcedistribution_controller.go	(revision f41e27d4bfb63f0aa0addb35889bae3d43aede56)
+++ b/pkg/controller/resourcedistribution/resourcedistribution_controller.go	(date 1680208342878)
@@ -59,6 +59,9 @@
 // Add creates a new ResourceDistribution Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller
 // and Start it when the Manager is Started.
 func Add(mgr manager.Manager) error {
+	if concurrentReconciles == 0 {
+		return nil
+	}
 	if !utildiscovery.DiscoverGVK(controllerKind) {
 		return nil
 	}
Index: pkg/controller/imagepulljob/imagepulljob_controller.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/pkg/controller/imagepulljob/imagepulljob_controller.go b/pkg/controller/imagepulljob/imagepulljob_controller.go
--- a/pkg/controller/imagepulljob/imagepulljob_controller.go	(revision f41e27d4bfb63f0aa0addb35889bae3d43aede56)
+++ b/pkg/controller/imagepulljob/imagepulljob_controller.go	(date 1680208342961)
@@ -66,6 +66,9 @@
 // Add creates a new ImagePullJob Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller
 // and Start it when the Manager is Started.
 func Add(mgr manager.Manager) error {
+	if concurrentReconciles == 0 {
+		return nil
+	}
 	if !utildiscovery.DiscoverGVK(controllerKind) || !utilfeature.DefaultFeatureGate.Enabled(features.KruiseDaemon) {
 		return nil
 	}
Index: pkg/controller/ephemeraljob/ephemeraljob_controller.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/pkg/controller/ephemeraljob/ephemeraljob_controller.go b/pkg/controller/ephemeraljob/ephemeraljob_controller.go
--- a/pkg/controller/ephemeraljob/ephemeraljob_controller.go	(revision f41e27d4bfb63f0aa0addb35889bae3d43aede56)
+++ b/pkg/controller/ephemeraljob/ephemeraljob_controller.go	(date 1681129421099)
@@ -55,6 +55,8 @@
 // Add creates a new ImagePullJob Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller
 // and Start it when the Manager is Started.
 func Add(mgr manager.Manager) error {
+	return nil
+
 	if !utildiscovery.DiscoverGVK(controllerKind) {
 		return nil
 	}
Index: pkg/controller/sidecarset/sidecarset_controller.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/pkg/controller/sidecarset/sidecarset_controller.go b/pkg/controller/sidecarset/sidecarset_controller.go
--- a/pkg/controller/sidecarset/sidecarset_controller.go	(revision f41e27d4bfb63f0aa0addb35889bae3d43aede56)
+++ b/pkg/controller/sidecarset/sidecarset_controller.go	(date 1680216335384)
@@ -58,6 +58,9 @@
 // Add creates a new SidecarSet Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller
 // and Start it when the Manager is Started.
 func Add(mgr manager.Manager) error {
+	if concurrentReconciles == 0 {
+		return nil
+	}
 	if !utildiscovery.DiscoverGVK(controllerKind) {
 		return nil
 	}
Index: pkg/controller/podunavailablebudget/podunavailablebudget_controller.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/pkg/controller/podunavailablebudget/podunavailablebudget_controller.go b/pkg/controller/podunavailablebudget/podunavailablebudget_controller.go
--- a/pkg/controller/podunavailablebudget/podunavailablebudget_controller.go	(revision f41e27d4bfb63f0aa0addb35889bae3d43aede56)
+++ b/pkg/controller/podunavailablebudget/podunavailablebudget_controller.go	(date 1680208347842)
@@ -87,6 +87,9 @@
 // Add creates a new PodUnavailableBudget Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller
 // and Start it when the Manager is Started.
 func Add(mgr manager.Manager) error {
+	if concurrentReconciles == 0 {
+		return nil
+	}
 	if !utildiscovery.DiscoverGVK(controllerKind) {
 		return nil
 	}
Index: pkg/controller/nodeimage/nodeimage_controller.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/pkg/controller/nodeimage/nodeimage_controller.go b/pkg/controller/nodeimage/nodeimage_controller.go
--- a/pkg/controller/nodeimage/nodeimage_controller.go	(revision f41e27d4bfb63f0aa0addb35889bae3d43aede56)
+++ b/pkg/controller/nodeimage/nodeimage_controller.go	(date 1680208342984)
@@ -78,6 +78,9 @@
 // Add creates a new NodeImage Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller
 // and Start it when the Manager is Started.
 func Add(mgr manager.Manager) error {
+	if concurrentReconciles == 0 {
+		return nil
+	}
 	if !utildiscovery.DiscoverGVK(controllerKind) || !utilfeature.DefaultFeatureGate.Enabled(features.KruiseDaemon) {
 		return nil
 	}
Index: pkg/controller/persistentpodstate/persistent_pod_state_controller.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/pkg/controller/persistentpodstate/persistent_pod_state_controller.go b/pkg/controller/persistentpodstate/persistent_pod_state_controller.go
--- a/pkg/controller/persistentpodstate/persistent_pod_state_controller.go	(revision f41e27d4bfb63f0aa0addb35889bae3d43aede56)
+++ b/pkg/controller/persistentpodstate/persistent_pod_state_controller.go	(date 1680208342839)
@@ -77,6 +77,9 @@
 // Add creates a new PersistentPodState Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller
 // and Start it when the Manager is Started.
 func Add(mgr manager.Manager) error {
+	if concurrentReconciles == 0 {
+		return nil
+	}
 	if !discovery.DiscoverGVK(KruiseKindPps) {
 		return nil
 	}
Index: pkg/controller/sidecarterminator/sidecar_terminator_controller.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/pkg/controller/sidecarterminator/sidecar_terminator_controller.go b/pkg/controller/sidecarterminator/sidecar_terminator_controller.go
--- a/pkg/controller/sidecarterminator/sidecar_terminator_controller.go	(revision f41e27d4bfb63f0aa0addb35889bae3d43aede56)
+++ b/pkg/controller/sidecarterminator/sidecar_terminator_controller.go	(date 1680208342940)
@@ -56,6 +56,9 @@
 // Add creates a new SidecarTerminator Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller
 // and Start it when the Manager is Started.
 func Add(mgr manager.Manager) error {
+	if concurrentReconciles == 0 {
+		return nil
+	}
 	if !utilfeature.DefaultFeatureGate.Enabled(features.SidecarTerminator) {
 		return nil
 	}
Index: pkg/controller/daemonset/daemonset_controller.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/pkg/controller/daemonset/daemonset_controller.go b/pkg/controller/daemonset/daemonset_controller.go
--- a/pkg/controller/daemonset/daemonset_controller.go	(revision f41e27d4bfb63f0aa0addb35889bae3d43aede56)
+++ b/pkg/controller/daemonset/daemonset_controller.go	(date 1681129541126)
@@ -66,13 +66,10 @@
 	kruiseclientset "github.com/openkruise/kruise/pkg/client/clientset/versioned"
 	"github.com/openkruise/kruise/pkg/client/clientset/versioned/scheme"
 	kruiseappslisters "github.com/openkruise/kruise/pkg/client/listers/apps/v1alpha1"
-	"github.com/openkruise/kruise/pkg/features"
 	kruiseutil "github.com/openkruise/kruise/pkg/util"
 	utilclient "github.com/openkruise/kruise/pkg/util/client"
 	utildiscovery "github.com/openkruise/kruise/pkg/util/discovery"
 	kruiseExpectations "github.com/openkruise/kruise/pkg/util/expectations"
-	utilfeature "github.com/openkruise/kruise/pkg/util/feature"
-	imagejobutilfunc "github.com/openkruise/kruise/pkg/util/imagejob/utilfunction"
 	"github.com/openkruise/kruise/pkg/util/inplaceupdate"
 	"github.com/openkruise/kruise/pkg/util/lifecycle"
 	"github.com/openkruise/kruise/pkg/util/ratelimiter"
@@ -130,14 +127,13 @@
 // Add creates a new DaemonSet Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller
 // and Start it when the Manager is Started.
 func Add(mgr manager.Manager) error {
+	if concurrentReconciles == 0 {
+		return nil
+	}
 	if !utildiscovery.DiscoverGVK(controllerKind) {
 		return nil
 	}
-	if !utildiscovery.DiscoverGVK(appsv1alpha1.SchemeGroupVersion.WithKind("ImagePullJob")) ||
-		!utilfeature.DefaultFeatureGate.Enabled(features.KruiseDaemon) ||
-		!utilfeature.DefaultFeatureGate.Enabled(features.PreDownloadImageForDaemonSetUpdate) {
-		isPreDownloadDisabled = true
-	}
+
 	r, err := newReconciler(mgr)
 	if err != nil {
 		return err
@@ -420,11 +416,6 @@
 			if err := dsc.createImagePullJobsForInPlaceUpdate(ds, old, cur); err != nil {
 				klog.Errorf("Failed to create ImagePullJobs for %s: %v", request, err)
 			}
-		} else {
-			// delete ImagePullJobs if revisions have been consistent
-			if err := imagejobutilfunc.DeleteJobsForWorkload(dsc.Client, ds); err != nil {
-				klog.Errorf("Failed to delete imagepulljobs for %s: %v", request, err)
-			}
 		}
 	}

Index: pkg/controller/cloneset/cloneset_controller.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/pkg/controller/cloneset/cloneset_controller.go b/pkg/controller/cloneset/cloneset_controller.go
--- a/pkg/controller/cloneset/cloneset_controller.go	(revision f41e27d4bfb63f0aa0addb35889bae3d43aede56)
+++ b/pkg/controller/cloneset/cloneset_controller.go	(date 1680208342976)
@@ -76,6 +76,9 @@
 // Add creates a new CloneSet Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller
 // and Start it when the Manager is Started.
 func Add(mgr manager.Manager) error {
+	if concurrentReconciles == 0 {
+		return nil
+	}
 	if !utildiscovery.DiscoverGVK(clonesetutils.ControllerKind) {
 		return nil
 	}
